<?php

use yii\helpers\Html;
use yii\grid\GridView;

/* @var $this yii\web\View */
/* @var $searchModel backend\modules\home\models\MhBannerSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '轮播图管理';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="mh-banner-index">

    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>

    <p>
        <?= Html::a('创建轮播图', ['create'], ['class' => 'btn btn-success']) ?>
    </p>

    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            ['class' => 'yii\grid\ActionColumn'],
            'id',
            [
                'format' => 'raw',
                'attribute' => 'cid',
                'value' => function($model) {
                    if($model->cid == 1){
                        return '<span class="btn btn-xs btn-info">电脑端</span>';
                    }else{
                        return '<span class="btn btn-xs btn-info">手机端</span>';
                    }
                    
                },
            ],
            'title',
            'subtitle',
            [
                'format' => 'raw',
                'attribute' => 'img_path',
                'value' => function($model) {
                    return '<img src="'.$model->img_path.'" style="height:100px;">';
                },
            ],
            //'url:url',
            'sort',
            'create_time:datetime',
        ],
    ]); ?>
</div>
